<?php 


$sql="select sl_lab_grupy_bad.id as id_gr_bad, upper(sl_lab_grupy_bad.nazwa) as nazwa_gr_bad, sl_lab_bad.id as id_bad, upper(sl_lab_bad.nazwa) as nazwa_bad 
from 
sl_lab_grupy_bad left join sl_lab_bad on sl_lab_bad.id_grupy = sl_lab_grupy_bad.id 
where sl_lab_grupy_bad.akt=1 and sl_lab_bad.akt=1";   

#echo $sql;

$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$bad_gr[$row['id_gr_bad']]=$row['nazwa_gr_bad'];
$bad[$row['id_gr_bad']][$row['id_bad']]=$row['nazwa_bad'];
}

?>





  <script type="text/javascript" src="js/jquery.elastic.js"></script>
<script type="text/javascript">
  $(document).ready(function(){
    $("#tabs").tabs();

    <?php 
    		foreach ($bad as $in=>$wa){
    	        foreach ($bad[$in] as $ind=>$war){
    	        	
    	        	echo '$("#bad'.$ind.'").click(function(){';
    	    		echo '$("#extra'.$ind.'").toggle();';
    	    		echo '});';
    	        	        }
    	}

    		?>
	

   
   
    });
  </script>



<?php  

echo '<form action="index.php" method="POST"><input type=submit value=Anuluj name="grafik" class="butt4"></form>';
echo '<form class="fancy" id="fancy" method="post" action="">';
echo '<div id="tabs">';
echo '<ul>';
foreach ($bad_gr as $i=>$w){
        echo '<li><a href="#'.$i.'"><span>'.$w.'</span></a></li>';
}
echo '</ul>';

echo '<br>';
$sql="select * from sl_firmy";
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$sl_f[$row[0]]=$row[1];
}
$sl_f[0]='Pełnopłatny';

echo '&nbsp;&nbsp;&nbsp;Płatnik:';   
form_auto_submit_2n('platnik', $sl_f);
foreach ($bad as $in=>$wa){
        echo '<div id="'.$in.'">';
        echo '<fieldset >';
   		echo '<legend>'.$bad_gr[$in].'</legend>';
   		echo '<ul>';
   		
     	#echo '<label for="cnaz">'.$bad_gr[$in].'</label>';
        foreach ($bad[$in] as $ind=>$war){
        	echo '<li>';
        	
     		echo '<input id=bad'.$ind.'  type="checkbox" name="bad_lab['.$ind.']" value="'.$war.'"  />'.$war.'<br/>';
   			echo '</li>';
        	
        	
        }
        
        echo '</ul>';
        echo '</fieldset>';
        echo '</div>';
}

echo '<li>';
echo '<input class="submit" name="form_dod_z_bad" type="submit" value="Zapisz"/>';
echo '</li>';       


foreach ($bad as $in=>$wa){
        foreach ($bad[$in] as $ind=>$war){
        	echo '<div id="extra'.$ind.'" style="display: none">'.$bad_gr[$in].' - '.$war.'</div>';
        	        }
}



echo '</div>';
?> 
